package main

/*
	1, web api
	2，router api
*/
import (
	"fmt"
	"net"
)

func main() {
	addr, err := net.ResolveTCPAddr("tcp", "0.0.0.0:12345")
	if err != nil {
		fmt.Println("resolve addr failed. ", err)
		return
	}

	listener, err := net.ListenTCP("tcp", addr)
	if err != nil {
		fmt.Println("listen tcp failed.", err)
		return
	}

	for {
		conn, err := listener.AcceptTCP()
		if err != nil {
			fmt.Println("accept failed.")
			continue
		}

		go handler(conn)
	}
}

//func ReadUntil()

func rcvHandler(conn *net.TCPConn, ch chan []byte) {
	headBuf := main([]byte, 4)
	for {
		conn.Read(headBuf)
	}
}

func handler(conn *net.TCPConn) {
	ChIn := make(chan []byte)
	ChOut := make(chan []byte)

	for {
		//
	}
}
